home *** CD-ROM | disk | FTP | other *** search
/ Monster Media 1994 #2 / Monster Media No. 2 (Monster Media)(1994).ISO / utils2 / tlb_a241.zip / HIGHUMM.DOC < prev    next >
Text File  |  1994-06-09  |  23KB  |  663 lines

  1.  
  2.  
  3.         
  4.  
  5.  
  6.                    Application Program Interface Specification
  7.  
  8.                                        for
  9.  
  10.                                    HIGHUMM.SYS
  11.  
  12.                                        of
  13.  
  14.                         THE LAST BYTE MEMORY MANAGER (tm)
  15.  
  16.  
  17.  
  18.  
  19.                                   Version 2.41
  20.  
  21.  
  22.  
  23.  
  24.  
  25.  
  26.  
  27.  
  28.  
  29.  
  30.                               Copyright (C) 1990-94
  31.                                All Rights Reserved
  32.  
  33.  
  34.                                        by
  35.  
  36.  
  37.                               KEY SOFTWARE PRODUCTS
  38.  
  39.                                 440 Ninth Avenue
  40.                         Menlo Park, California 94025-1802
  41.                                   415-364-9847
  42.  
  43.  
  44.  
  45.  
  46.  
  47.  
  48.  
  49.  
  50.  
  51.  
  52.  
  53.  
  54.  
  55.  
  56.         The Last Byte Memory Manager is a trademark of Key Software Products
  57.  
  58.  
  59.  
  60.         
  61.  
  62.  
  63.                                 TABLE OF CONTENTS
  64.  
  65.  
  66.  
  67.         CHAPTER 1 - APPLICATION PROGRAM INTERFACE TO HIGHUMM.SYS       1
  68.            1.1  XMS Upper Memory Blocks     .......................    1
  69.            1.2  Bank-Switch Memory       ..........................    3
  70.            1.3  Summary Of HIGHUMM.SYS Functions     ..............    5
  71.               1.3.1  Function 0: Request a UMB memory block  ......    5
  72.               1.3.2  Function 1: Release a UMB memory block  ......    5
  73.               1.3.3  Function 2: Request a Bank-Switch memory block    5
  74.               1.3.4  Function 3: Release a Bank-Switch memory block    6
  75.               1.3.5  Function 4: Transfer data to/from high memory     6
  76.               1.3.6  Function 5: Get a Word from a Bank-Switch bloc    6
  77.               1.3.7  Function 6: Put a Word to a Bank-Switch block.    6
  78.               1.3.8  Function 7: Put a Byte to a Bank-Switch block.    7
  79.               1.3.9  Function 8: Enable Bank-Switch Memory    .....    7
  80.               1.3.10  Function 9: Disable Bank-Switch Memory    ...    7
  81.               1.3.11  Function 10: Assign a name to a UMB or.......    7
  82.               1.3.12  Function 11: Locate a UMB block by name .....    8
  83.               1.3.13  Function 12: Locate a BSW block by name .....    8
  84.            1.4  Final Notes       .................................    9
  85.  
  86.  
  87.  
  88.  
  89.  
  90.  
  91.  
  92.  
  93.  
  94.  
  95.  
  96.  
  97.  
  98.  
  99.  
  100.  
  101.  
  102.  
  103.  
  104.  
  105.  
  106.  
  107.  
  108.  
  109.  
  110.  
  111.  
  112.  
  113.  
  114.  
  115.  
  116.  
  117.  
  118.  
  119.  
  120.         
  121.  
  122.  
  123.  
  124.         Jun 09, 1994  Programmer's Interface to HIGHUMM.SYS             1
  125.  
  126.  
  127.           CHAPTER 1 - APPLICATION PROGRAM INTERFACE TO HIGHUMM.SYS    
  128.  
  129.  
  130.         HIGHUMM.SYS  is a device driver that lets application programmers
  131.         access  upper  memory  between  640k  and 1Meg.  It requires that
  132.         LASTBYTE  be installed first, and automatically loads itself into
  133.         upper  memory  without the need to use either HIGHDRVR or the DOS
  134.         5 DEVICEHIGH command.  
  135.  
  136.         HIGHUMM provides two methods of accessing high memory: 
  137.  
  138.  
  139.         1.1 XMS Upper Memory Blocks      
  140.  
  141.         If  an  Extended  Memory  Specification  (XMS)  driver  (such  as
  142.         HIMEM.SYS)  has  already  been loaded, HIGHUMM will link into it,
  143.         providing   an  implementation  of  the  two  XMS  functions  for
  144.         accessing  what  the XMS specification refers to as "Upper Memory
  145.         Blocks"  (UMB's).   Although  described in the XMS specification,
  146.         the  UMB functions have not been implemented in the current (June
  147.         1990) and previous versions of HIMEM.SYS.  
  148.  
  149.         If  an XMS driver has not been loaded, then HIGHUMM will become a
  150.         UMB-Only  XMS  device driver, providing support for XMS functions
  151.         00h   (Get   Version  Number),  10h  (Allocate  UMB  Block),  11h
  152.         (Deallocate  UMB  Block).   All  other  XMS functions will return
  153.         failure, indicating that the function is not implemented.  
  154.  
  155.                 ┌─────────────────────────────────────────────────┐
  156.                 │ If another XMS device driver is used (e.g., to  │
  157.                 │ provide management of Extended Memory or the    │
  158.                 │ High Memory Area), it must be loaded before     │
  159.                 │ HIGHUMM.SYS.                                    │ 
  160.                 └─────────────────────────────────────────────────┘ 
  161.  
  162.         Upper  Memory  Blocks  (UMBs)  are  blocks of memory available on
  163.         some  80x86  based  machines which are located between DOS's 640K
  164.         limit  and  the  1MB  address  boundary.   The  number, size, and
  165.         location  of these blocks vary widely depending upon the types of
  166.         hardware  adapter cards installed in the machine.  By definition,
  167.         this   memory   is  DOS-accessible,  but  does  NOT  include  the
  168.         Bank-Switch memory supported by LASTBYTE.  
  169.  
  170.         On  80286  and  80386  based machines, XMS allows DOS programs to
  171.         utilize  Extended  Memory  in  a  consistent, machine independent
  172.         manner.   With some restrictions, XMS adds almost 64K of Extended
  173.         Memory  to  the  640K  which  DOS  programs  can access directly.
  174.         Depending  on  available  hardware,  XMS  may  provide  even more
  175.         memory  (UMB's)  to DOS programs.  XMS also provides DOS programs
  176.         with a standard method of storing data in Extended Memory.  
  177.  
  178.  
  179.  
  180.  
  181.         Copyright (C) 1990-94, Key Software Products. All Rights Reserved
  182.  
  183.  
  184.         Jun 09, 1994  Programmer's Interface to HIGHUMM.SYS             2
  185.  
  186.  
  187.         The  XMS Specification for MS-DOS was jointly developed by Lotus,
  188.         Intel,  Microsoft,  and  AST  Research.   The  specification  was
  189.         published  on July 19, 1988 and released to the public domain and
  190.         is  not  confidential  or  proprietary,  but the specification is
  191.         still  the  copyright  and  property of these companies.  You may
  192.         obtain  a copy from Microsoft Corporation, 16011 NE 36th Way, Box
  193.         97017,  Redmond,  WA  98073,  or  by  calling  Microsoft at (800)
  194.         426-9400.  
  195.  
  196.         Access to the UMB's through XMS is a four step process: 
  197.  
  198.                 1.  Test for the existence of the XMS driver.  
  199.                 2.  Obtain the address of the XMS control function.  
  200.                 3.  Invoke the Request UMB or Release UMB function.  
  201.                 4.  Check for success or failure.  
  202.  
  203.         This is best explained by an example: 
  204.  
  205.                 ...  
  206.                 mov     ax,4300h        ; XMS driver installed? 
  207.                 int     2Fh 
  208.                 cmp     al,80h 
  209.                 jne     NoXMSDriver 
  210.                 ...  
  211.                 mov     ax,4310h        ; Get adrs of XMS Ctl Func 
  212.                 int     2Fh 
  213.                 mov     WORD PTR [XMSControl],bx 
  214.                 mov     WORD PTR [XMSControl+2],es 
  215.                 ...  
  216.                 mov     ah,10h          ; Request a UMB memory block 
  217.                 mov     dx,size_in_paragraphs 
  218.                 call    [XMSControl]    ; a FAR call! 
  219.                 cmp     ax,1 
  220.                 jne     Request_Failed 
  221.  
  222.                 ; If request was successful: 
  223.                 ; -------------------------- 
  224.                 ; AX = 1 
  225.                 ; BX = Segment address of allocated block 
  226.                 ; DX = Actual size of block (same as requested size) 
  227.  
  228.                 ; If request failed: 
  229.                 ; ------------------ 
  230.                 ; AX = 0 
  231.                 ; DX = size of largest available in paragraphs 
  232.                 ; Error Codes:  BL = 80h (Not implemented/installed) 
  233.                 ;               BL = B0h (Smaller UMB available) 
  234.                 ;               BL = B1h (No UMB available) 
  235.  
  236.                 mov     ah,11h          ; Release a UMB memory block 
  237.                 mov     dx,segment_address_of_umb 
  238.  
  239.  
  240.  
  241.         Copyright (C) 1990-94, Key Software Products. All Rights Reserved
  242.  
  243.  
  244.         Jun 09, 1994  Programmer's Interface to HIGHUMM.SYS             3
  245.  
  246.  
  247.                 call    [XMSControl]    ; a FAR call! 
  248.                 cmp     ax,1 
  249.                 jne     Release_Failed 
  250.  
  251.                 ; If request was successful: 
  252.                 ; -------------------------- 
  253.                 ; AX = 1 
  254.  
  255.                 ; If request failed: 
  256.                 ; ------------------ 
  257.                 ; AX = 0 
  258.                 ; Error Codes:  BL = 80h (Not implemented/installed) 
  259.                 ;               BL = B2h (invalid segment number) 
  260.  
  261.  
  262.         HIGHMEM lists such UMB memory blocks as "MS-DOS XMS UMB".  
  263.  
  264.  
  265.         1.2 Bank-Switch Memory        
  266.  
  267.         The  second  method  of  accessing  high memory is by opening the
  268.         device  "KSP$UMM"  and  performing  an  IOCTL Read of four bytes.
  269.         This  obtains  the  offset and segment address of an extended UMB
  270.         control  function  that  provides access to Bank-Switch memory as
  271.         well  as  normal  UMB  blocks.   Using HIGHUMM.SYS in this manner
  272.         does  not  require  that  an  XMS  driver  such  as  HIMEM.SYS be
  273.         loaded.  For example: 
  274.  
  275.  
  276.         Device_Name     db     'KSP$UMM',0   ;  HIGHUMM.SYS  device  name
  277.         HIGHUMM_Ctl   dw   0,0         ; far ptr to ctl func 
  278.  
  279.                 ...  
  280.                 mov     ax,3D00h        ; open file or device 
  281.                 mov     dx,OFFSET Device_Name   ; DS:DX => device name 
  282.                 int     21h 
  283.                 jc      Open_Failed     ; (HIGHUMM.SYS not installed) 
  284.                 mov     handle,ax       ; save handle 
  285.  
  286.                 mov     ax,4400h        ; ioctl: get device attributes 
  287.                 mov     bx,handle 
  288.                 int     21h 
  289.                 jc      Attb_Failed     ; (HIGHUMM.SYS not functioning) 
  290.                 test    dl,80h          ; is this a device or a filename 
  291.                 jz      Not_Device      ; File called "KSP$UMM" exists! 
  292.  
  293.                 mov     ax,4402h        ; IOCTL Read (BX = handle) 
  294.                 mov     bx,handle 
  295.                 mov     dx,OFFSET HIGHUMM_Ctl   ; DS:DX => read buffer 
  296.                 mov     cx,4            ; read *EXACTLY* four bytes 
  297.                 int     21h 
  298.  
  299.  
  300.  
  301.         Copyright (C) 1990-94, Key Software Products. All Rights Reserved
  302.  
  303.  
  304.         Jun 09, 1994  Programmer's Interface to HIGHUMM.SYS             4
  305.  
  306.  
  307.  
  308.                 pushf 
  309.                 mov     ah,3Eh          ; Close device (BX = handle) 
  310.                 mov     bx,handle 
  311.                 int     21h 
  312.                 popf 
  313.  
  314.                 jc      IOCTL_Error     ; (HIGHUMM.SYS not functioning) 
  315.  
  316.                 ; Offset of control function is in "HIGHUMM_Ctl" 
  317.                 ; Segment of control function is in "HIGHUMM_Ctl+2" 
  318.  
  319.  
  320.         Once  you  have the address of the extended control function from
  321.         HIGHUMM.SYS, you can invoke any of the following 13 functions: 
  322.  
  323.                 Function        Description                     Class 
  324.                 --------        -----------                     -------- 
  325.  
  326.                 AH = 0  Request a UMB memory block              STANDARD 
  327.                 AH = 1  Release a UMB memory block              STANDARD 
  328.  
  329.                 AH = 2  Request a Bank-Switch memory block      EXTRA 
  330.                 AH = 3  Release a Bank-Switch memory block      EXTRA 
  331.                 AH = 4  Transfer data to/from high memory       EXTRA 
  332.                 AH = 5  Get a Word from a Bank-Switch block     EXTRA 
  333.                 AH = 6  Put a Word to a Bank-Switch block       EXTRA 
  334.                 AH = 7  Put a Byte to a Bank-Switch block       EXTRA 
  335.                 AH = 8  Enable Bank-Switch Memory               EXTRA 
  336.                 AH = 9  Disable Bank-Switch Memory              EXTRA 
  337.                 AH = A  Assign a name to a UMB or BSW block     EXTRA 
  338.                 AH = B  Locate a UMB block by name              EXTRA 
  339.                 AH = C  Locate a BSW block by name              EXTRA 
  340.  
  341.                 ┌─────────────────────────────────────────────────┐
  342.                 │ Support for the "EXTRA" class of functions      │
  343.                 │ requires use of the "/EXTRA" option on the      │
  344.                 │ HIGHUMM.SYS command line:                       │
  345.                 └─────────────────────────────────────────────────┘ 
  346.  
  347.                 DEVICE=C:\TLBMM\HIGHUMM.SYS /EXTRA 
  348.  
  349.                 ("/EXTRA" may be abbreviated as simply "/E".) 
  350.  
  351.         These  function  numbers  are  different  than  those  used  with
  352.         XMSControl  even though three of them are otherwise equivalent to
  353.         XMS  functions 10h and 11h!  Calling one of the HIGHUMM functions
  354.         is  similar  to  calling  the  XMS  functions.   For  example, to
  355.         request  a  Bank-Switch memory block, the following code would be
  356.         used:  
  357.  
  358.  
  359.  
  360.  
  361.         Copyright (C) 1990-94, Key Software Products. All Rights Reserved
  362.  
  363.  
  364.         Jun 09, 1994  Programmer's Interface to HIGHUMM.SYS             5
  365.  
  366.  
  367.                 mov     ah,2                    ; Request a BSW block 
  368.                 mov     dx,paragraphs 
  369.                 call    [HIGHUMM_Control]       ; a FAR call! 
  370.                 cmp     ax,1 
  371.                 jne     Request_Failed          ; BL contains error code 
  372.                                                 ; DX = largest available 
  373.  
  374.                 ; Success: BX contains segment number 
  375.  
  376.         For  all  HIGHUMM.SYS  functions, the error codes are the same as
  377.         returned by the XMS driver: 
  378.  
  379.                 AX = 0001h      Function successful 
  380.                      0000h      Function failed; error code in BL 
  381.  
  382.                 BL = 80h        Function not implemented 
  383.                      B0h        Insuf. memory; smaller block available 
  384.                      B1h        Insuf. memory; no block available 
  385.                      B2h        Invalid block segment number 
  386.  
  387.  
  388.         1.3 Summary Of HIGHUMM.SYS Functions      
  389.  
  390.         1.3.1 Function 0: Request a UMB memory block  
  391.  
  392.              Parameters:     AH = 0
  393.                              DX = Size of requested block in paragraphs
  394.  
  395.              Returns:        AX = Status
  396.                              BX = Segment Number or Error Code
  397.                              DX = Size of requested block/largest block
  398.  
  399.              Description:    Identical to XMS function 10h
  400.  
  401.  
  402.         1.3.2 Function 1: Release a UMB memory block  
  403.  
  404.              Parameters:     AH = 1
  405.                              DX = Segment number of memory block
  406.  
  407.              Returns:        AX = Status
  408.                              BL = Error Code
  409.  
  410.              Description:    Identical to XMS function 11h
  411.  
  412.  
  413.         1.3.3 Function 2: Request a Bank-Switch memory block  
  414.  
  415.              Parameters:     AH = 2
  416.                              DX = Size of requested block in paragraphs
  417.  
  418.  
  419.  
  420.  
  421.         Copyright (C) 1990-94, Key Software Products. All Rights Reserved
  422.  
  423.  
  424.         Jun 09, 1994  Programmer's Interface to HIGHUMM.SYS             6
  425.  
  426.  
  427.              Returns:        AX = Status
  428.                              BX = Segment Number or Error Code
  429.                              DX = Size of requested block/largest block
  430.  
  431.              Description:    Similar to function 0 for regular UMB blocks,
  432.                              except that HIGHMEM lists these blocks as
  433.                              "Bank-Switch UMB".
  434.  
  435.  
  436.         1.3.4 Function 3: Release a Bank-Switch memory block  
  437.  
  438.              Parameters:     AH = 3
  439.                              DX = Segment number of memory block
  440.  
  441.              Returns:        AX = Status
  442.                              BL = Error Code
  443.  
  444.              Description:    Similar to function 1 for regular UMB blocks.
  445.  
  446.  
  447.         1.3.5 Function 4: Transfer data to/from high memory  
  448.  
  449.              Parameters:     AH = 4
  450.                              DS:SI = Segment:Offset of source
  451.                              ES:DI = Segment:Offset of destination
  452.                              CX = byte count
  453.  
  454.              Returns:        AX = Status (Never returns failure)
  455.  
  456.              Description:    Enables Bank-Switch Memory, copies data between
  457.                              the specified source and destination, then
  458.                              disables Bank-Switch memory.
  459.  
  460.  
  461.         1.3.6 Function 5: Get a Word from a Bank-Switch block
  462.  
  463.              Parameters:     AH = 5
  464.                              ES:DI = Segment:Offset of word to read
  465.  
  466.              Returns:        AX = Status (Never returns failure)
  467.                              DX = WORD from BSW Block
  468.  
  469.              Description:    Enables Bank-Switch Memory, loads DX from the
  470.                              specified location, then disables Bank-Switch
  471.                              memory.
  472.  
  473.  
  474.  
  475.  
  476.  
  477.  
  478.  
  479.  
  480.  
  481.         Copyright (C) 1990-94, Key Software Products. All Rights Reserved
  482.  
  483.  
  484.         Jun 09, 1994  Programmer's Interface to HIGHUMM.SYS             7
  485.  
  486.  
  487.         1.3.7 Function 6: Put a Word to a Bank-Switch block
  488.  
  489.              Parameters:     AH = 6
  490.                              DX = Word to put into BSW Block
  491.                              ES:DI = Segment:Offset of word to write
  492.  
  493.              Returns:        AX = Status (Never returns failure)
  494.  
  495.              Description:    Enables Bank-Switch Memory, stores DX into the
  496.                              specified location, then disables Bank-Switch
  497.                              memory.
  498.  
  499.  
  500.         1.3.8 Function 7: Put a Byte to a Bank-Switch block
  501.  
  502.              Parameters:     AH = 7
  503.                              DL = Byte to put into BSW Block
  504.                              ES:DI = Segment:Offset of byte to write
  505.  
  506.              Returns:        AX = Status (Never returns failure)
  507.  
  508.              Description:    Enables Bank-Switch Memory, stores DL into the
  509.                              specified location, then disables Bank-Switch
  510.                              memory.
  511.  
  512.  
  513.         1.3.9 Function 8: Enable Bank-Switch Memory    
  514.  
  515.              Parameters:     AH = 8
  516.                              DS:SI = Segment:Offset of 6-byte save area
  517.  
  518.              Returns:        AX = Status (Never returns failure)
  519.  
  520.              Description:    Disables interrupts, saves the memory controller
  521.                              state in a 6-byte save area within the 
  522.                              application program, and enables Bank-Switch
  523.                              memory so that data within it may be accessed.
  524.  
  525.  
  526.         1.3.10 Function 9: Disable Bank-Switch Memory    
  527.  
  528.              Parameters:     AH = 9
  529.                              DS:SI = Segment:Offset of 6-byte save area
  530.  
  531.              Returns:        AX = Status (Never returns failure)
  532.  
  533.              Description:    Reloads the state of the memory controller from a
  534.                              6-byte save area in the application program and
  535.                              restores the previous interrupt enable status.
  536.  
  537.  
  538.  
  539.  
  540.  
  541.         Copyright (C) 1990-94, Key Software Products. All Rights Reserved
  542.  
  543.  
  544.         Jun 09, 1994  Programmer's Interface to HIGHUMM.SYS             8
  545.  
  546.  
  547.         1.3.11 Function 10: Assign a name to a UMB or
  548.  
  549.              Parameters:     AH = 0Ah
  550.                              DX = Segment number of memory block
  551.                              DS:SI = Segment:Offset of 8-byte blank-padded
  552.                                      name
  553.  
  554.              Returns:        AX = Status
  555.                              BX = Error Code
  556.  
  557.              Description:    Copies 8 bytes to the name field of the
  558.                              allocated UMB or BSW memory block.
  559.  
  560.  
  561.         1.3.12 Function 11: Locate a UMB block by name 
  562.  
  563.              Parameters:     AH = 0Bh
  564.                              DS:SI = Segment:Offset of 8-byte blank-padded
  565.                                      name
  566.  
  567.              Returns:        AX = Status
  568.                              BX = Segment Number or Error Code
  569.                              DX = Size of block
  570.  
  571.              Description:    Locates a UMB memory block by its 1-8 character
  572.                              name.  All 8 bytes of name are compared; letter
  573.                              with different case do not match.
  574.  
  575.  
  576.         1.3.13 Function 12: Locate a BSW block by name 
  577.  
  578.              Parameters:     AH = 0Ch
  579.                              DS:SI = Segment:Offset of 8-byte blank-padded
  580.                                      name
  581.  
  582.              Returns:        AX = Status
  583.                              BX = Segment Number or Error Code
  584.                              DX = Size of block
  585.  
  586.              Description:    Locates a BSW memory block by its 1-8 character
  587.                              name.  All 8 bytes of name are compared; letter
  588.                              with different case do not match.
  589.  
  590.  
  591.         IMPORTANT!  A  call  to  function 8 must be followed by a call to
  592.         function  9, and without enabling interrupts in between.  This is
  593.         because  while  Bank-Switch  memory  is enabled, all adapter RAMs
  594.         (including  display  buffers) and any ROMs which are not shadowed
  595.         are  disabled;  thus  any  code (either your own program or a TSR
  596.         activated  by  the  timer  tick)  that  attempts  to access these
  597.         resources  will fail.  Also, it is important to execute this code
  598.  
  599.  
  600.  
  601.         Copyright (C) 1990-94, Key Software Products. All Rights Reserved
  602.  
  603.  
  604.         Jun 09, 1994  Programmer's Interface to HIGHUMM.SYS             9
  605.  
  606.  
  607.         quickly  to  minimize  the  amount  of  time  that interrupts are
  608.         disabled.  
  609.  
  610.  
  611.         1.4 Final Notes        
  612.  
  613.         The  only valid use of Bank-Switch memory is to store data! Never
  614.         load  a program into Bank-Switch memory and then reference it via
  615.         a  JMP  or  CALL  -  it won't be there!  For example, you may NOT
  616.         load   a  TSR  into  Bank-Switch  memory  and  expect  it  to  be
  617.         accessible when it's activating interrupt occurs.  
  618.  
  619.         UMB's  (regular  and  Bank-Switched) are NOT automatically free'd
  620.         at  program  termination  like  regular  memory allocated by your
  621.         program  using  DOS  function  72 (48 hex).  For example, if your
  622.         program  uses  a  UMB for a temporary buffer, you must be sure to
  623.         release the UMB before terminating the program.  
  624.  
  625.  
  626.  
  627.  
  628.  
  629.  
  630.  
  631.  
  632.  
  633.  
  634.  
  635.  
  636.  
  637.  
  638.  
  639.  
  640.  
  641.  
  642.  
  643.  
  644.  
  645.  
  646.  
  647.  
  648.  
  649.  
  650.  
  651.  
  652.  
  653.  
  654.  
  655.  
  656.  
  657.  
  658.  
  659.  
  660.  
  661.         Copyright (C) 1990-94, Key Software Products. All Rights Reserved
  662.  
  663.